package org.azmat.mybatis.SQL.Service.Impl;

import jakarta.transaction.Transactional;
import org.azmat.mybatis.SQL.Entity.Book;
import org.azmat.mybatis.SQL.Mapper.BookMapper;
import org.azmat.mybatis.SQL.Service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookMapper bookMapper;

    @Override
    public List<Book> selectAllBooks() {
        return bookMapper.selectAllBook();
    }

    @Override
    public Book selectByIdBook(int id) {
        return bookMapper.selectByIdBook(id);
    }

    @Override
    @Transactional
    public void insertBook(Book book) {
        bookMapper.insertBook(book);
    }

    @Override
    @Transactional
    public void updateBook(Book book) {
        bookMapper.updateBook(book);
    }

    @Override
    @Transactional
    public void deleteBook(int id) {
        bookMapper.deleteBook(id);
    }

    @Override
    public List<Book> searchBooks(Book book) {
        return bookMapper.searchBooks(book);
    }

    @Override
    @Transactional
    public void deleteBooks(int[] id) {
        bookMapper.deleteBooks(id);
    }


}
